<?php 
require_once 'classes/Resource.php';
include('includes/confirm.php');

$resource = New Resources();
$page_name = add_book;

if($_POST['addbook']){
	$add_book_response = "addbook";
	if( $_POST['year']<=3000 && $_POST['year']>=1980){
	if(!empty($_POST['title'])
		&& !empty($_POST['year'])
		&& !empty($_POST['publisher'])
		&& !empty($_POST['ISBN'])){
			$add_book_response = $resource->add_book(
				$_POST['title'],
				$_POST['year'],
				$_POST['publisher'],
				$_POST['ISBN']);
	} else {
		$add_book_response = "Some values were left blank.";
	}
	}
	else{
		$add_book_response = "Sorry, Type the correct year information";
	}
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <?php include('includes/head.php'); ?>
<body>
<div id="wrapper">
    <?php include('includes/header.php'); ?>
    <?php include('includes/menu.php'); ?>
    
  <div id="page">
    <div id="page-bgtop">
      <div id="content">
       <h2> Add Book </h2>
        <div id="addmedia">
            <form method="post" action="">           
                <p>
                    <label for="title">Title: </label>
                    <input type="text" name="title" />
                </p>
                
                <p>
                    <label for="year">Year: </label>
                    <input type="text" name="year" />
                </p>

                <p>
                    <label id= "length" for="length">Publisher: </label>
                    <input type="text" name="publisher" />
                </p>

                <p>
                    <label for="rating">ISBN: </label>
                    <input type="text" name="ISBN" />
                </p>

                <p>
                    <input type="submit" id="submit" name="addbook" value="Add Book" />
                </p>
            </form>
	    <?php if(isset($add_book_response)) echo "<h4 class='alert'>" . $add_book_response . "</h4>"; ?>
        </div><!--end login-->
        
        
      </div>
      <!-- end div#content -->
       <?php include('includes/add_sidebar.php'); ?>
      
      <div style="clear: both; height: 1px"></div>
    </div>
  </div>
  <!-- end div#page -->
    <?php include('includes/footer.php'); ?>
</div> <!-- end div#wrapper -->
</body>
</html>

